package com.nf.health.app.myfamily.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;

import com.nf.health.app.R;
import com.nf.health.app.activity.global.BaseActivity;
import com.nf.health.app.utils.ViewUtil;
/** 
 * @ClassName: OldPersonalSettingActivity 
 * @Description: 老人机设置页面
 * @author Ian 
 * @date 2015-11-18 下午3:20:36 
 *  
 */
public class OldPersonalSettingActivity extends BaseActivity {

	String value,type,phone,touserid;

	private RelativeLayout old_setting_name,old_setting_phone,old_setting_call,old_setting_sos;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setTitleBar(R.layout.titlebar_base);
		setContent(R.layout.activity_old_personal_setting);
		initView();
		initDate();
	}

	private void initDate() {
		// TODO Auto-generated method stub
		Intent intent = getIntent();
		value = intent.getStringExtra("imei");
		phone = intent.getStringExtra("phone");
		touserid = intent.getStringExtra("touserid");

		provider.requestCheckImei(value,"oldmobile");

	}

	private void initView() {
		// TODO Auto-generated method stub
		ViewUtil.setText(this, R.id.titlebar_title_tv,"设置老年手机");
		old_setting_name = (RelativeLayout) findViewById(R.id.old_setting_name);
		old_setting_phone = (RelativeLayout) findViewById(R.id.old_setting_phone);
		old_setting_call = (RelativeLayout) findViewById(R.id.old_setting_call);
		old_setting_sos = (RelativeLayout) findViewById(R.id.old_setting_sos);



		old_setting_name.setOnClickListener(new OnClickListener() {//设置老人机名称

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(OldPersonalSettingActivity.this,OldSettongNameActivity.class);
				intent.putExtra("imei",value);
				intent.putExtra("phone",phone);
				intent.putExtra("touserid",touserid);
				intent.putExtra("type","oldMobile");
				startActivity(intent);
			}
		});
		old_setting_phone.setOnClickListener(new OnClickListener() {//设置老人机联系方式

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(OldPersonalSettingActivity.this,OldSettongPhoneActivity.class);
				intent.putExtra("imei",value);
				intent.putExtra("phone",phone);
				intent.putExtra("touserid",touserid);
				startActivity(intent);
			}
		});
		old_setting_call.setOnClickListener(new OnClickListener() {//设置老人机快速拨号

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(OldPersonalSettingActivity.this,OldSettongCallActivity.class);
				intent.putExtra("imei",value);
				startActivity(intent);
			}
		});
		old_setting_sos.setOnClickListener(new OnClickListener() {//设置老人机sos

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(OldPersonalSettingActivity.this,OldSettongSosActivity.class);
				intent.putExtra("imei",value);
				startActivity(intent);
			}
		});
	}
	@Override
	public void handleActionSuccess(String actionName, Object object) {
		super.handleActionSuccess(actionName, object);
		if (actionName.equals("oldmobile")) {

			String istrue = object+"";

			if(istrue.contains("不支持修改此手机")){
				old_setting_name.setVisibility(View.VISIBLE);
			}else{
				old_setting_name.setVisibility(View.VISIBLE);
				old_setting_phone.setVisibility(View.VISIBLE);
				old_setting_call.setVisibility(View.VISIBLE);
				old_setting_sos.setVisibility(View.VISIBLE);
			}
		}
	}

}
